<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="../../static/js/jquery-3.0.0.js"></script>
</head>
<body>
    <form action="register" method="post">
        <div>
           <div>name: <input type="text" id="regname" name="name" onblur="checkname()"><span style="display:none">用户名已注册</span></div>    
           <div>pass: <input type="text" name="pwd"></div>
                <input type="submit" value="regist">
        </div>
               
                
        
        
    </form>
    <script>
       
    function checkname(){
        console.log($("#regname").val());
        $.ajax({
            url:"isName",
            data:{"name":$("#regname").val()},
            type:"post",
            success:function($res){
                if($res==1){
                    $("#regname").siblings().get(0).style.display="inline-block";
                }else{
                    $("#regname").siblings().get(0).style.display="none";
                }
            }

        })
    }
    </script>
</body>
</html>